package com.ajx.todo.project.adplatform;

import android.arch.lifecycle.LifecycleActivity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.ajx.todo.R;
import com.ajx.todo.project.adplatform.utils.CommonUtils;
import com.ajx.todo.project.adplatform.utils.PlatformAttribute;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by lai on 2017/9/9.
 */

public class WelcomeActivity extends LifecycleActivity {
    @BindView(R.id.iv_bg)
    ImageView ivBg;
    @BindView(R.id.iv_qrcode)
    ImageView ivQrcode;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ad_welcome);
        ButterKnife.bind(this);
        init();
        showLogoAndQrcode();
        entryWorkUI();
    }

    private void init() {

    }


    private void entryWorkUI() {
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                startActivity(new Intent(WelcomeActivity.this, ADActivity.class));
                finish();
            }
        }, 3000);// TODO: 2017/9/9 进入主页面的时间配置读取
    }


    private void showLogoAndQrcode() {
        String machineId = PlatformAttribute.getMachineId();
        Bitmap idCode = CommonUtils.generateBitmap(machineId, 350, 350);
        if (idCode != null) {
            ivQrcode.setImageBitmap(idCode);
        }
    }
}
